﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class admin_adminQxdo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!Page.IsPostBack)
        {
            adminQxdo();
        }
    }
    public void adminQxdo() {
        try
        {
            string myids = "";
            if (Request["qxs"] != null) myids = Request["qxs"].ToString().Trim();
            string userid = "";
            if (Request["userid"] != null) userid = Request["userid"].ToString().Trim();
            if (userid.Trim().Length > 0)
            {
                //先删除原有权限
                DB.doNonQuery("delete from admin_qx where adminId=" + userid);
                //添加新权限
                if (myids.Trim().Length > 0)
                {
                    string[] qxArr = myids.Split(',');
                    Response.Write(myids);
                    if (qxArr != null && qxArr.Length > 0)
                    {
                        for (int i = 0; i < qxArr.Length; i++)
                        {
                            if (qxArr[i].Trim().Length > 0)
                            {
                                Response.Write("insert into admin_qx(channelid,adminId) values(" + qxArr[i] + "," + userid + ")");
                                DB.doNonQuery("insert into admin_qx(channelid,adminId) values(" + qxArr[i] + "," + userid + ")");
                            }
                        }
                    }
                }
            }
            Response.Redirect("adminQx.aspx?userid=" + userid);
        }
        catch (Exception error) {
            Response.Write(error.ToString());
        }
    }
}
